<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store, must-revalidate"> 
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> 
<META HTTP-EQUIV="expires" CONTENT="0">
<meta name="viewport" content="height=device-height,width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
<title>旅程列表</title>
<link href="img/css/css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.tabstyle{
	line-height: 41px;
	text-align: center;
	display: block;
	float: left;
	height: 41px;
	width: 50%;
	font-size:14px;
}

.tabstyle_d{
	line-height: 41px;
	text-align: center;
	display: block;
	float: left;
	height: 37px;
	width: 49%;
	font-size: 14px;
	border-bottom-width: 4px;
	border-bottom-style: solid;
	border-bottom-color: #fdb92d;
}
</style>
<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="js/jquery.json.min.js"></script>  
<script type="text/javascript" src="js/jsonMsg.js"></script>  
<script type="text/javascript" src="js/QueryStringParser.js"></script>
</head>

<body>
<div class="tab3">
     <font style="cursor:pointer;" id="list1" onclick="handleTripList(1,4)"><div class="tabstyle_d">最近的旅程</div></font>
     <font style="cursor:pointer;" id="list2" onclick="handleTripList(2,4)"><div class="tabstyle line_left">结束的旅程</div></font>
     <!--font style="cursor:pointer;" id="list3" onclick="handleTripList(3,4)"><div class="tabstyle line_left">退出的旅程</div></font-->
</div>
<!--div class="sort" id="orderContain">
     <div class="sortstyle"><font style="cursor:pointer;" id="order1" onclick="handleTripList(1,1)"><span class="sortstyle_yellow">过期时间</span></font></div>
     <div class="sortstyle"><font style="cursor:pointer;" id="order2" onclick="handleTripList(1,2)">参与人数</font></div>
     <div class="sortstyle"><font style="cursor:pointer;" id="order3" onclick="handleTripList(1,3)">创建者</font></div>
</div-->
<div class="sort" id="orderContain">
     <div class="sortstyle2"><font style="cursor:pointer;" id="order1" onclick="handleTripList(0,4)"><span class="sortstyle_yellow2">我创建的</span></font></div>
     <div class="sortstyle2"><font style="cursor:pointer;" id="order2" onclick="handleTripList(0,5)">被邀请的</font></div>
</div>
<font id="contain">

</font>
<!--End of list group-->
<div class="bottom_btn">
     <p class="ico_group4" onclick="addTrip();" style="cursor:pointer;" ><i class="iconfont img">&#xe600;</i>增加旅程</p>
</div>
<script type="text/javascript">
var latLon = "";
var openId = queryString.getParam("openid");
var innerContain = "";  

function addTrip(){
	window.location.href="add_trip.html?openid="+	openId;
}

var topListType = 1;
function handleTripList(listType,orderType){
	if(openId==null || openId==""){
		//return false;	
	}else{
		if(listType==0){
				listType = topListType;
		}else{	
			topListType = listType;
		}
		
		if(orderType==1){
				$("#order1").html('<span class="sortstyle_yellow">过期时间</span>');
				$("#order2").html('参与人数');
				$("#order3").html('创建者');
		}else if(orderType==2){
				$("#order1").html('过期时间');
				$("#order2").html('<span class="sortstyle_yellow">参与人数</span>');
				$("#order3").html('创建者');
		}else if(orderType==3){
				$("#order1").html('过期时间');
				$("#order2").html('参与人数');
				$("#order3").html('<span class="sortstyle_yellow">创建者</span>');	
		}else if(orderType==4){
				$("#order1").html('<span class="sortstyle_yellow2">我创建的</span>');	
				$("#order2").html('被邀请的');
		}else if(orderType==5){
				$("#order1").html('我创建的');
				$("#order2").html('<span class="sortstyle_yellow2">被邀请的</span>');	
		}
				
		if(listType==1){
				
				$("#list1").html('<div class="tabstyle_d">最近的旅程</div>');
				$("#list2").html('<div class="tabstyle line_left">结束的旅程</div>');
				//$("#list3").html('<div class="tabstyle line_left">退出的旅程</div>');
		}else if(listType==2){
				$("#list1").html('<div class="tabstyle line_left">最近的旅程</div>');
				$("#list2").html('<div class="tabstyle_d">结束的旅程</div>');
				//$("#list3").html('<div class="tabstyle line_left">退出的旅程</div>');
		}else{
				$("#list1").html('<div class="tabstyle line_left">最近的旅程</div>');
				$("#list2").html('<div class="tabstyle line_left">结束的旅程</div>');
				//$("#list3").html('<div class="tabstyle_d">退出的旅程</div>');
		}
		var dataStr = {   
        ListType: listType,  
        OrderType: orderType,  
        Cursor: 0,  
        Limit:15,
        Direction:0
    };  
		
		var bodyStr = popBody('ListTrip',dataStr);
		var request = popRequest('ListTrip',openId,bodyStr);
		//调用了jquery.json 库  
		var encoded = $.toJSON( request );  
		var jsonStr = encoded;  

		$.ajax({  
		url : actionStr,  
		type : 'POST',  
		data : jsonStr,  
		dataType : 'json',  
		contentType : 'application/json',  
		success : function(data, status, xhr) {  
		//         Do Anything After get Return data  
							if(data.portalResp.Data.trips && data.portalResp.Data.trips.length>0){
			          $.each(data.portalResp.Data.trips, function(index){
	 									if(index==0){
	 										$("#contain").html("");	
	 										innerContain = "";
	 									}
			              var urlString = "trip_leader.html";
			              var rightContent = "<span class='green'>火热进行中...</span>";
			              if(data.portalResp.Data.trips[index].isActive){
			              		urlString = "trip_leader.html";//代表active trip
			              }else{
			              		rightContent = data.portalResp.Data.trips[index].ValidDate+"过期";
			              		
			              }
			              
			              var flag = 0;
			              if(data.portalResp.Data.trips[index].isActive){
			              	flag = 1;	
			              }
			              
			              if(data.portalResp.Data.trips[index].TripLeader==openId){
			              		innerContain+=("<a href='trip_leader.html?isActive="+flag+"&openid="+openId+"&tripid="+data.portalResp.Data.trips[index].TripID+"'>"); 
			              }else{
			              		innerContain+=("<a href='trip_member.html?isActive="+flag+"&openid="+openId+"&tripid="+data.portalResp.Data.trips[index].TripID+"'>"); 
			              }
//			              if(data.portalResp.Data.trips[index].isActive){
//			              	innerContain+=("<a href='trip_leader.html?isActive=1&openid="+openId+"&tripid="+data.portalResp.Data.trips[index].TripID+"'>"); 
//			              }else{
//				              if(data.portalResp.Data.trips[index].TripLeader==openId){
//				              		innerContain+=("<a href='trip_leader.html?isActive=0&openid="+openId+"&tripid="+data.portalResp.Data.trips[index].TripID+"'>"); 
//				              }else{
//				              		innerContain+=("<a href='trip_member.html?openid="+openId+"&tripid="+data.portalResp.Data.trips[index].TripID+"'>"); 
//				              }
//			            	}
			              
										innerContain+=("	<div class='list_group'>");
										innerContain+=("	      <img src='"+data.portalResp.Data.trips[index].LeaderPortrait+"' width='50' height='50' class='user_pic'>");
										innerContain+=("	      <div class='list_text'>");
										innerContain+=("	           <div class='list_title'>"+data.portalResp.Data.trips[index].Title+"</div>");
										innerContain+=("	           <div class='list_user_status'>");
										innerContain+=("	                <p class='user'><i class='iconfont user'>&#xe609;</i>参与人数："+data.portalResp.Data.trips[index].MemberNumber+"人</p>");
										innerContain+=("	                <p class='status'>"+rightContent+"</p>");
										innerContain+=("	           </div>");
										innerContain+=("	      </div>");
										innerContain+=("	</div>");
										innerContain+=("</a>");
										
										
			          }); 
			          $("#contain").html(innerContain);
		        }else{
		        	$("#contain").html("");		
		        } 
		},  
		Error : function(xhr, error, exception) {  
		    // handle the error.    
		    alert(exception.toString());  
		}  
		});  
	}	
}
$(document).ready(function(){
	handleTripList(1,4);
});


</script>


</body>
</html>
